class Api::V1::GamesController < Api::V1::BaseController
  skip_before_action :authenticate_request!
  before_action :authenticate_request

  def index
    @games = Game.all
    if params[:beted].presence && params[:beted]
      @games = @games.joins(:bets).where("bets.user_id = ?", @current_user.id)
    end
    @games = @games.order("begin_at DESC").page(params[:page]).per(params[:per])
  end
  
end
